package com.systop.ltbook.book.press.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Store;

import com.systop.core.model.BaseModel;
import com.systop.ltbook.book.model.Book;

/**
 * 出版社类
 * @author DU
 */
@Entity
@Table(name = "presses")
@SuppressWarnings("serial")
public class Press extends BaseModel {

	/** 主键 */
	private Integer id;

	/** 名称 */
	private String name;

	/** 名称字母 */
	private String charName;
	
	/** 描述 */
	private String descn;
	
	/** 对应图书 */
	private Set<Book> books = new HashSet<Book>();
	
	@Id
	@GeneratedValue(generator = "hibseq")
	@GenericGenerator(name = "hibseq", strategy = "hilo")
	@Column(name = "ID", nullable = false)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "descn")
  @Type(type = "text")
  @Field(name = "descn", index = Index.TOKENIZED, store = Store.YES)
	public String getDescn() {
  	return descn;
  }

	public void setDescn(String descn) {
  	this.descn = descn;
	}
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "press")
	public Set<Book> getBooks() {
  	return books;
  }

	public void setBooks(Set<Book> books) {
  	this.books = books;
  }

	@Column(name = "char_name")
	public String getCharName() {
  	return charName;
  }

	public void setCharName(String charName) {
  	this.charName = charName;
  }
}
